﻿namespace InkType.ViewModel

open InkType.ViewModel.SavedTypefaces
open System
open System.Collections.Generic
open System.Windows
open System.Windows.Data


type GlyphAdvanceMode =
    | ``Full Width Advance`` = 0
    | ``Half Width Advance`` = 1
    | ``Absolute Advance`` = 2
    //| ``Relative Advance`` = 3


module GlyphAdvanceModes =
    let GetGlyphWidth =
        function
        | GlyphAdvanceMode.``Full Width Advance`` -> fun _ -> GlyphMetrics.Height
        | GlyphAdvanceMode.``Half Width Advance`` -> fun _ -> GlyphMetrics.Height / 2.
        | GlyphAdvanceMode.``Absolute Advance`` -> fun width -> width
        | _ -> raise <| NotImplementedException ()

    let NeedParam =
        function
        | GlyphAdvanceMode.``Full Width Advance`` -> false
        | GlyphAdvanceMode.``Half Width Advance`` -> false
        | GlyphAdvanceMode.``Absolute Advance`` -> true
        | _ -> raise <| NotImplementedException ()

    let NeedParamConverter =
        { new IValueConverter with
            member x.Convert (value, _, _, _) =
                NeedParam (value :?> _)
                |> function
                    | true -> Visibility.Visible
                    | false -> Visibility.Collapsed
                |> box
            member x.ConvertBack (_, _, _, _) =
                raise <| NotImplementedException () }



